﻿using System.Collections.Generic;
using System.Threading.Tasks;
using SensorDrone.Net;
using SimpleMvvmToolkit;

namespace SensorDroneStudio.Services
{
    [ServiceAgentExport(typeof (ISensorDroneService), AgentType = AgentType.Real)]
    internal class SensorDroneService : ISensorDroneService
    {
        private readonly SensorDroneProvider _provider = new SensorDroneProvider();

        public async Task<IEnumerable<ISensorDrone>> ScanAsync()
        {
            IEnumerable<ISensorDrone> drones = await _provider.ScanAsync();
            foreach (ISensorDrone drone in drones)
            {
                await drone.ConnectAsync();
            }
            return drones;
        }

        public void Stop()
        {
            _provider.Stop();
        }
    }
}